package com.wy.w_ui.ui.recyclerview;

import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

public abstract class WDataItem<DATA,VH extends RecyclerView.ViewHolder>{

    private WAdapter adapter;
    private DATA data;
    public WDataItem(DATA data){
        this.data = data;
    }


    public abstract void onBindData(RecyclerView.ViewHolder holder, int position);

    /**
     * @return 返回item的布局资源id
     */
    public int getItemLayoutRes(){
        return -1;
    }

    /**
     * @param parent
     * @return 返回item的视图view
     */
    public View getItemView(ViewGroup parent){
        return null;
    }

    public void setAdapter(WAdapter adapter) {
        this.adapter = adapter;
    }

    /**
     * 刷新列表
     */
    public final void refreshItem(){

        adapter.refreshItem(this);
    }

    /**
     * 移除item
     */
    public final void removeItem(){
        adapter.removeItem(this);
    }

    /**
     * 该 item 在列表上占据几列
     * @return
     */
    public int getSpanSize(){
        return 0;
    }


}
